<template>
	<view>
		<button @click="callSetStorage()" type="primary">setStorage</button>
		<button @click="getStirage()">获取缓存</button>
		<button @click="callStoInfo()">获取字段列表</button>
		<button @click="callRemove()" type="warn">删除</button>
		<button @click="callClear()" type="warn">清空</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				
			}
		},
		methods: {
			callSetStorage() {
				console.log("callSetStorage--->userName wyh");
				uni.setStorage({
					key:"userName",
					data:"wyh",
					success() {
						console.log("存储userName,成功回调");
					},
					fail() {
						console.log("存储userName,失败回调");
					},
					complete() {
						console.error("存储userName,完成回调");
					}
				})
			},
			getStorage() {
				console.log("getStorage--->userName wyh");
				uni.getStorage({
					key:"account",
					success:function(result) {
						console.log("获取本地缓存成功: "+result.data);
					},
					fail:function(result) {
						console.log("获取本地缓存失败: "+result.errMsg);
					},
				})
			},
			callStoInfo() {
				console.log("callStoInfo--->");
				uni.getStorageInfo({
					success:function(result) {
						console.log("callStoInfo--->" +result.keys);
						console.log("callStoInfo--->" +JSON.stringify(result));
						console.log("callStoInfo--->" +result.currentSize);
					},
				})
			},
			callRemove() {
				uni.removeStorage({
					key:"wuyanhong",
					success:function(result) {
						console.log("callRemove--->" +result.key);
						console.log("callStoInfo--->" +result.stringify(result));
						console.log("callStoInfo--->" +result.currentSize);
					},
				})
			},
			callClear() {
				uni.clearStorage()
			}
		}
	}
</script>

<style>
button{
	margin: 30rpx;
}
</style>
